<template>

  <div class="content">
    <!-- 我的 -->
    <div class="myorderform">
      <div class="myset">
        <img :alt="userInfo?userInfo.nickName:''" :src="myInfo.avatar" />
        <div v-if="myInfo">{{myInfo.nickName}}</div>
        <div v-else>请登录</div>
      </div>
      <div v-for="item,index in rightColumn" :key="index" @click="tabtop(index)" :class="current == index ? 'goodsbuy goodsbuyatv' : 'goodsbuy'">{{item }}</div>

    </div>
    <!-- 订单 -->

    <div class="orderform" v-if="myInfo">
      <mySurvey :myInfo="myInfo" v-if="current == 0" />
      <rechargeMoney v-if="current == 1" />
      <!--在线充值-->
      <GoodsOrde v-if="current == 2" />
      <!--商品订单-->
      <RechargeOrde v-if="current == 3" />
      <realName :myInfo="myInfo" v-if="current == 4" />

    </div>
    <div class="orderform" v-else></div>

    <!-----------------提现窗口-------------------------->
    <!-- <el-dialog width="450px" center title="提现" :close-on-click-modal="false" :visible.sync="dialogTableVisible">

      <el-form label-width="100px" label-position="left" ref="deposit" :model="deposit" :rules="rules">
        <el-form-item prop="depositMoney" label="提现金额">
          <el-input size="mini" @input="deposit.depositMoney=deposit.depositMoney.replace(/[^\d.]/g,'')" v-model="deposit.depositMoney" placeholder="请输入提现金额"></el-input>
        </el-form-item>
        <el-form-item prop="depositPassword" label="提现密码">
          <el-input size="mini" v-model="deposit.depositPassword" placeholder="请输入提现密码"></el-input>
        </el-form-item>

      </el-form>
      <el-button class="recharg-but" :disabled="loading" @click="withdraw" type="danger">确认提现</el-button>
    </el-dialog> -->

  </div>
</template>

<script>
import GoodsOrde from './myComponents/goodsOrde.vue' // 商品订单
import RechargeOrde from './myComponents/rechargeOrde.vue' // 充值订单
import rechargeMoney from './myComponents/rechargeMoney.vue' // 在线订单
import mySurvey from './myComponents/mySurvey.vue' // 账号预览
export default {
  components: { GoodsOrde, RechargeOrde, rechargeMoney, mySurvey },

  data () {
    return {
      rightColumn: ['账户预览', '在线充值', '商品订单', '充值订单'],
      dialogTableVisible: false,
      myInfo: '',
      loading: false,
      disabled: false,
      tableData: [],
      searchinput: '',
      current: 0,
      indent: 1,
      deposit: {
        depositMoney: '', // 提现金额
        depositPassword: '' // 提现密码
      },
      rules: {
        depositMoney: [
          { required: true, message: '请输入提现金额', trigger: 'blur' },
          {
            validator: function (rule, value, callback) {
              if (value <= 0) {
                callback(new Error('提现金额需大于0'))
              } else {
                callback()
              }
            }
          }
        ],
        depositPassword: [
          { required: true, message: '请输入提现密码', trigger: 'blur' }
        ]
      }
    }
  },
  computed: {
    userInfo () {
      if (localStorage.getItem('token')) {
        this.getInfo()
      } else {
        this.myInfo = ''
        this.$router.replace('./')
      }
      return this.$store.state.userInfo
    }
  },

  mounted () {
    var e = this.$route.query
    if (e.id) {
      this.current = e.id
    }
  },
  methods: {
    getInfo () {
      this.$apis.getInfo().then(res => {
        this.myInfo = res.data.data
      })
    },
    tabtop (e) {
      this.current = e

      if (e == 4) {
        this.init()
      }
    },
    orderform (e) {
      this.indent = e
    },

    withdraw () {
      this.$refs.deposit.validate(valid => {
        if (valid) {
          this.loading = true
          this.$apis.moneyApply(this.deposit).then(res => {
            if (res.data.errno == 0) {
              this.$notify.success({
                title: '成功',
                message: '提现申请成功'
              })

              this.getInfo()
            } else {
              this.$notify.error({
                title: '错误',
                message: res.data.errmsg
              })
            }
            this.dialogTableVisible = false
            this.loading = false
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.con-t-select {
  margin-top: 0px;
}
.content {
  display: flex;
  min-height: 100vh;
}
.myorderform {
  flex: 1;
  background-color: #fafafa;
}
.myset {
  text-align: center;
  padding: 70px 20px 50px;
  font-size: 16px;
  img {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    margin-bottom: 10px;
  }
  div {
    span {
      color: #d1483f;
    }
  }
}
.myorderform-title {
  font-size: 18px;
  margin-bottom: 30px;
  text-align: center;
}
.goodsbuy {
  padding: 15px 0px;
  color: #828282;
  font-size: 18px;
  cursor: pointer;
  text-align: center;
}
.goodsbuyatv {
  border-left: 4px solid #d82141;
  background-color: #fff;
}
.orderform {
  background-color: #fff;
  padding: 60px 40px;
  flex: 4;
  box-sizing: border-box;
}
.allorders {
  display: flex;
  margin-bottom: 20px;
}
.cancellation-order {
  border-right: 2px solid #ddd;
  padding: 0px 30px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
}
.cancellation-active {
  color: #d82141;
}
.cancellation-order:last-child {
  border: none;
}
.cancellation-order:first-child {
  padding-left: 0;
}
.uni-input {
  border: 1px solid #e4e4e4;
  width: 30%;
  border-radius: 10px;
  padding: 10px 0;
  padding-left: 20px;
  margin-bottom: 40px;
}
.indent-select {
  display: flex;
  .uni-data-select {
    margin-right: 10px;
  }
  img {
    width: 80px;
    height: 60px;
  }
}
.uni-stat__select {
  margin-right: 40px;
  margin-bottom: 40px;
}
.seedetails {
  color: #fff;
  background: linear-gradient(#d82141, #f36638);
}

.search-programa {
  margin: 20px 0px;
  display: flex;
  align-items: center;
  .search-but {
    width: 40px;
    height: 28px;
    background: url("../assets/static/select.png") no-repeat;
    background-size: contain;
    border: none;
    margin-left: 10px;
  }
  .search-input {
    width: 250px;
  }
}
.recharge-hd {
  border-left: 3px solid #d82141;
  padding: 2px 10px;
  margin-bottom: 30px;
}
.recharge-bd {
  width: 500px;
  margin-left: 150px;
}

.recharg-but {
  margin-left: 100px;
  margin-top: 20px;
}

.qrCodeUrl,
.out {
  width: 350px;
  height: 350px;
}

.out {
  background: url("../assets/static/t-09.png") no-repeat center top 50px;
  background-size: 128px;
  text-align: center;
  line-height: 400px;
}

.particulars {
  margin: 30px 0px;
  padding: 15px;
  border-top: 1px solid #efefef;
  border-bottom: 1px solid #efefef;
}
.particulars-item {
  display: flex;
  line-height: 30px;
  b {
    color: #444444;
    font-size: 14px;
    flex: 1;
  }
  span {
    color: #888888;
    font-size: 16px;
    flex: 3;
  }
}
</style>